Skip to content

Commit f89c73d

Browse files
authored
Merge pull request #6405 from emilghittasv/playwright-coverage-expansion
Playwright expand searchbar coverage on different pages
2 parents 7303cd6 + 240b91e commit f89c73d

File tree

4 files changed

+291
-53
lines changed

4 files changed

+291
-53
lines changed

playwright_tests/pages/search/search_page.py

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
class SearchPage(BasePage):
66
# Locators belonging to the searchbar.
77
SEARCHBAR_LOCATORS = {
8-
"searchbar": "//form[@id='support-search-masthead']/input[@id='search-q']",
8+
"searchbar_homepage": "//form[@id='support-search-masthead']/input[@id='search-q']",
9+
"searchbar_aaq": "//form[@id='question-search-masthead']/input[@id='search-q']",
10+
"searchbar_sidebar": "//form[@id='support-search-sidebar']/input[@id='search-q']",
11+
"hidden_searchbar": "//form[@id='hidden-search']/input[@id='search-q']",
912
"searchbar_search_button": "//form[@id='support-search-masthead']/button",
1013
"search_results_header": "//div[@class='home-search-section--content']/h2",
11-
"popular_searches": "//p[@class='popular-searches']/a"
14+
"popular_searches": "//p[@class='popular-searches']/a",
15+
"search_results_section": "//main[@id='search-results-list']"
1216
}
1317

1418
# Locators belonging to the search results filter
@@ -41,6 +45,9 @@ class SearchPage(BasePage):
4145
def __init__(self, page: Page):
4246
super().__init__(page)
4347

48+
def _wait_for_visibility_of_search_results_section(self):
49+
self._wait_for_selector(self.SEARCHBAR_LOCATORS["search_results_section"])
50+
4451
"""
4552
Actions against the search results
4653
"""
@@ -58,6 +65,7 @@ def get_search_result_summary_text_of_a_particular_article(self, article_title)
5865
Args:
5966
article_title (str): The title of the article
6067
"""
68+
self._wait_for_visibility_of_search_results_section()
6169
return self._get_text_of_element(f"//h3[@class='sumo-card-heading']/"
6270
f"a[normalize-space(text())='{article_title}']/../"
6371
f"../p")
@@ -68,6 +76,7 @@ def is_a_particular_article_visible(self, article_title: str) -> bool:
6876
Args:
6977
article_title (str): The title of the article
7078
"""
79+
self._wait_for_visibility_of_search_results_section()
7180
return self._is_element_visible(f"//h3[@class='sumo-card-heading']/"
7281
f"a[normalize-space(text())='{article_title}']")
7382

@@ -77,11 +86,13 @@ def click_on_a_particular_article(self, article_title: str):
7786
Args:
7887
article_title (str): The title of the article
7988
"""
89+
self._wait_for_visibility_of_search_results_section()
8090
self._click(f"//h3[@class='sumo-card-heading']/"
8191
f"a[normalize-space(text())='{article_title}']")
8292

8393
def get_all_bolded_content(self) -> list[str]:
8494
"""Get all the bolded content of the search results"""
95+
self._wait_for_visibility_of_search_results_section()
8596
return self._get_text_of_elements(self.SEARCH_RESULTS_LOCATORS
8697
["all_bolded_article_content"])
8798

@@ -91,6 +102,7 @@ def get_all_search_results_article_bolded_content(self, article_title: str) -> l
91102
Args:
92103
article_title (str): The title of the article
93104
"""
105+
self._wait_for_visibility_of_search_results_section()
94106
if "'" in article_title:
95107
parts = article_title.split("'")
96108
if len(parts) > 1:
@@ -110,10 +122,12 @@ def get_all_search_results_article_bolded_content(self, article_title: str) -> l
110122

111123
def get_all_search_results_article_titles(self) -> list[str]:
112124
"""Get all the titles of the search results"""
125+
self._wait_for_visibility_of_search_results_section()
113126
return self._get_text_of_elements(self.SEARCH_RESULTS_LOCATORS["search_results_titles"])
114127

115128
def get_all_search_results_articles_summary(self) -> list[str]:
116129
"""Get all the summaries of the search results"""
130+
self._wait_for_visibility_of_search_results_section()
117131
return self._get_text_of_elements(self.SEARCH_RESULTS_LOCATORS
118132
["search_results_articles_summary"])
119133

@@ -123,6 +137,7 @@ def get_locator_of_a_particular_article(self, article_title: str) -> Locator:
123137
Args:
124138
article_title (str): The title of the article
125139
"""
140+
self._wait_for_visibility_of_search_results_section()
126141
return self._get_element_locator(f"//h3[@class='sumo-card-heading']/"
127142
f"a[normalize-space(text())='{article_title}']")
128143

@@ -136,20 +151,38 @@ def is_search_content_section_displayed(self) -> bool:
136151

137152
def get_text_of_searchbar_field(self) -> str:
138153
"""Get the text of the search bar field"""
139-
return self._get_element_input_value(self.SEARCHBAR_LOCATORS["searchbar"])
154+
return self._get_element_input_value(self.SEARCHBAR_LOCATORS["searchbar_homepage"])
140155

141-
def fill_into_searchbar(self, text: str):
156+
def fill_into_searchbar(self, text: str, is_aaq=False, is_sidebar=False):
142157
"""Fill into the search bar
143158
144159
Args:
145160
text (str): The text to fill into the search bar
161+
is_aaq (bool): Whether the search bar is on the AAQ flow pages
162+
is_sidebar (bool): Whether the search bar is on the sidebar
146163
"""
147-
self.clear_the_searchbar()
148-
self._fill(self.SEARCHBAR_LOCATORS["searchbar"], text)
164+
if is_aaq:
165+
self.clear_the_searchbar(is_aaq=True)
166+
self._fill(self.SEARCHBAR_LOCATORS["searchbar_aaq"], text)
167+
elif is_sidebar:
168+
self._fill(self.SEARCHBAR_LOCATORS["searchbar_sidebar"], text)
169+
else:
170+
self.clear_the_searchbar()
171+
self._fill(self.SEARCHBAR_LOCATORS["searchbar_homepage"], text)
172+
173+
def clear_the_searchbar(self, is_aaq=False, is_sidebar=False):
174+
"""Clear the search bar
149175
150-
def clear_the_searchbar(self):
151-
"""Clear the search bar"""
152-
self._clear_field(self.SEARCHBAR_LOCATORS["searchbar"])
176+
Args:
177+
is_aaq (bool): Whether the search bar is on the AAQ flow pages
178+
is_sidebar (bool): Whether the search bar is on the sidebar
179+
"""
180+
if is_aaq:
181+
self._clear_field(self.SEARCHBAR_LOCATORS["searchbar_aaq"])
182+
elif is_sidebar:
183+
self._clear_field(self.SEARCHBAR_LOCATORS["hidden_searchbar"])
184+
else:
185+
self._clear_field(self.SEARCHBAR_LOCATORS["searchbar_homepage"])
153186

154187
def click_on_search_button(self):
155188
"""Click on the search button"""
@@ -188,4 +221,5 @@ def click_on_a_particular_side_nav_item(self, product_name: str):
188221
"""
189222
def get_search_results_header(self) -> str:
190223
"""Get the search results header"""
224+
self._wait_for_visibility_of_search_results_section()
191225
return self._get_text_of_element(self.SEARCHBAR_LOCATORS["search_results_header"])

playwright_tests/tests/ask_a_question_tests/aaq_tests/test_posted_questions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pytest_check import check
77
from playwright_tests.core.utilities import Utilities
88
from playwright.sync_api import expect, TimeoutError, Page
9-
109
from playwright_tests.messages.contribute_messages.con_tools.moderate_forum_messages import (
1110
ModerateForumContentPageMessages)
1211
from playwright_tests.messages.ask_a_question_messages.AAQ_messages.question_page_messages import (
@@ -19,7 +18,6 @@
1918

2019

2120
# C2191086, C2191094, C2191263, C2191263, C2191087, C2191088
22-
# T5696747, T5696755, T5696748, T5696751, T5696749
2321
@pytest.mark.postedQuestions
2422
@pytest.mark.parametrize("username", ['TEST_ACCOUNT_MESSAGE_5', ''])
2523
def test_posted_question_details(page: Page, username):
@@ -64,7 +62,7 @@ def test_posted_question_details(page: Page, username):
6462
sumo_pages.aaq_flow.deleting_question_flow()
6563

6664

67-
# T5696750, T5696753
65+
# T5696750, T5696753, C2103331
6866
@pytest.mark.postedQuestions
6967
def test_edit_this_question_functionality_not_signed_in(page: Page):
7068
utilities = Utilities(page)

playwright_tests/tests/ask_a_question_tests/product_solutions_page_tests/test_product_solutions_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from playwright_tests.pages.sumo_pages import SumoPages
1111

1212

13-
# C890370, C890374
13+
# C890370, C890374, C890372
1414
@pytest.mark.productSolutionsPage
1515
def test_featured_articles_redirect(page: Page, is_chromium):
1616
if is_chromium:

0 commit comments

Comments
 (0)